//
//  MoreHouseTypeCollectionCell.m
//  YiJuZhangShou2.0
//
//  Created by URANUS on 16/3/27.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "MoreHouseTypeCollectionCell.h"
#import "UIImageView+FadeWebCache.h"
#import "Masonry.h"
@interface MoreHouseTypeCollectionCell()
@property (nonatomic, strong) UIImageView *houseTypeImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation MoreHouseTypeCollectionCell

#pragma mark - Initialize
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpConstraints];
    }
    return self;
}
#pragma mark - Private
- (void)setUpConstraints{
   [self.houseTypeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       make.left.top.right.equalTo(self.contentView);
       make.height.equalTo(self.houseTypeImageView.mas_width).multipliedBy(0.75);
   }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.top.lessThanOrEqualTo(self.houseTypeImageView.mas_bottom);
    }];
}

#pragma mark - Getter
- (UIImageView *)houseTypeImageView{

    if (_houseTypeImageView == nil) {
        _houseTypeImageView = [UIImageView new];
        _houseTypeImageView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_houseTypeImageView];
    }
    return _houseTypeImageView;
}

- (UILabel *)titleLabel{

    if (_titleLabel == nil) {
        _titleLabel = [UILabel new];
        _titleLabel.font = TextFont14;
        _titleLabel.textColor = TextColor120;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

#pragma mark - Setter
- (void)setModel:(MoreHouseTypeModel *)model{
    [self.houseTypeImageView setImageWithURLString:model.houseTypePicture andPlaceHolderString:DefaultNetPicture4To3];
    [self.titleLabel setText:model.houseTypeName];
}

@end
